gmpcfandomcom-20200214-history
GMPC SHOUT SSH REMOTE
Improved guid can be found here: http://blog.sarine.nl/2011/02/06/gmpcmpdssh-listen-to-your-music-from-home-at-work/ This tutorial describes how to setup MPD, GMPC and the gmpc-shout plugin so you can remotely listen to the music played by MPD using GMPC. Use Case * When you are at work and want to listen to the music you have at home. * You are sitting with you laptop in the garden and want to listen to the music playing inside on your stereo. Assumptions This are conditions needed for this tutorial: These are not part of the tutorial. * You have MPD running with a working httpd output. * GMPC and MPD are not running on the same machine. * Your network is fast enough to stream the audio + MPD protocol overhead. * You have the gmpc-shout plugin. * You are running the latest GMPC and gmpc-shout (0.19.100). Earlier versions will work, but might need a different steps in setting up gmpc-shout. * You can SSH from your MPD machine to your GMPC machine. * mplayer is installed on the machine running GMPC. * For this example: ** The host running MPD is on hostname: mpdhost.example.com. ** The host running MPD is called SERVER ** The client running GMPc is called cLIENT ** MPD listens on port 6600 and accecpts connections from localhost. ** MPD's httpd output listens on port 8000 and accept connections from localhost. ** On CLIENT port 6600 and 8000 are available. Setting up the tunnel We are going to use SSH to tunnel the protocol and the stream from SERVER to CLIENT. We define this in the config file of ssh, so we do not have to pass remember the right command line arguments every time Open on CLIENT ~/.ssh/config (create if needed) Add the following lines: host mpdserver hostname mpdhost.example.com LocalForward 6600 localhost:6600 LocalForward 8000 localhost:8000 (ssh man ssh_config for more information.) now start the tunnel by executing the command "ssh mpdserver" on CLIENT. This will do a remote login to mpdserver and create the tunnel, leave this open. NOTE: Closing the remote ssh session will close an idle tunnel. If the tunnel is in use, ssh will stay active until the tunnel is no longer used. Setting up GMPC On client start gmpc, configure a profile (preferences->connection) mpdserver with the following information: name: mpdserver hostname: localhost port: 6600 and hit connect. This should connect you to the MPD running on SERVER. Now we are going to setup gmpc-shout. Go to preferences->plugins and enable the Shout plugin. A new preferences entry should appear in the left pane. Select this. Here you see a command line where you can enter the command gmpc should execute to do the actual playback of the stream. In this example I use mplayer, other cli player are possible. In the entry box enter the following line: mplayer -nocache http://localhost:8000/ On ubuntu you might want to tell mplayer to use pulseaudio: mplayer -ao pulse -nocache http://localhost:8000/ Listening to music Hit the play button. (stop/pause mpd if it was allready playing), this should start mplayer in the background and start the playback off the stream. The actual delay between what you hear and see in GMPC is depending on caching. Normally this should be around 1 second. NOTE: If the connection is bad, mplayer might disconnect on song change, this needs to be worked around in gmpc-shout (see below). Note: In the lower left corner of gmpc (in the status bar) there is an icon for gmpc-shout, this indicate if mplayer is running or disconnected. Things that need to be improved * GMPC-shout needs to reconnect when connection fail. Use a exponential back off method for this. * Add a context menu to the status icon allowing you to reconnect and/or stop the plugin. * Support selectively enabling the plugin for certain connection profiles. * Allow to add ${SERVER_IP} in the gmpc-shout url, that replaces it with the hostname for the current profile.